<!-- author: aarendsen (alef@jteam.nl) -->
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="../styles.css"/>
	</head>
	<body>
		<h2><code>spring:transform</code></h2>
		<h3>org.springframework.web.servlet.tags.TransformTag</h3>
		<hr>
		<p>
		</p>
		<p>
			<table class="tag" width="100%">
				<tr>
					<td class="tagname"><b><code>spring:transform (since 1.0)</code></b></td>
				</tr>
				<tr>
					<td class="tagsection"><b>General information</b></td>
				<tr>
				<tr>
					<td colspan="2">
						The <code>spring:transform</code> tag provides you with support for
						transforming properties not contained by a <i>command</i> using
						PropertyEditors associated with the <i>command</i>. Suppose you
						have 10 dates you want to let the user choose from, you need to
						transform the date in the same way you would do, when using
						the <code>spring:bind</code> tag. The <code>spring:transform</code>
						tag provides this support.<br>
						<b>Note:</b> this tag can only be used <i>inside</i> a <code>spring:bind</code>
						tag!
					</td>
				</tr>
				<tr>
					<td class="tagsection"><b>Attributes</b></td>
				<tr>
				<tr>
					<td class="tagheader" valign="top"><b>value</b></td>
				</tr>
				<tr>
					<td>The value to transform. This is the actual object you want to have
						transform (for instance a Date). Using the PropertyEditor
						that is currently in use by the <code>spring:bind</code> tag
					</td>
				</tr>
				<tr>
					<td>required: yes</td>
				</tr>
				<tr>
					<td>el-support: yes</tD>
				</tr>
				<tr>
					<td class="tagheader" valign="top"><b>var</b></td>
				</tr>
					<td>The string to use when binding the result to the page,
						request, session or application scope. If not specified,
						the result gets outputted to the writer (directly to the JSP i.e.).
					</td>
				</tr>
				<tr>
					<td>required: no</td>
				</tr>
				<tr>
					<td>el-support: yes</tD>
				</tr>
				<tr>
					<td class="tagheader" valign="top"><b>scope</b></td>
				</tr>
				<tr>
					<td>The scope to use when exported the result to a variable.
						This attribute is only used when <code>var</code> is also set.
						Possible values are <code>page</code>, <code>request</code>, 
						<code>session</code> and <code>application</code>
					</td>
				</tr>
				<tr>
					<td>required: no</td>
				</tr>
				<tr>
					<td>el-support: yes</tD>
				</tr>
				<tr>
					<td class="tagsection"><b>Variables</b></td>
				</tr>
				<tr>
					<td valign="top">none</td>
				</tr>
				<tr>
					<td class="tagsection" colspan="2"><b>Also have a look at</b></td>
				<tr>
				<tr>
					<td>the <a href="BindTag.html"><code>spring:bind</code></a> tag,
					to see in which tag you need to nest this tag</td>
				<tr>
				<tr>
					<td class="tagsection"><b>A possible usecase</b></td>
				</tr>
				<td>
					Consider the following:
					<ul>
						<li>SimpleFormController that controls <code>Contract</code> object</li>
						<li>Amongst others, the Person object has a <code>contractType</code> property</li>				
						<li>Available contract types are <code>silver</code>, <code>gold</code> and
							<code>premium</code> and they are instance of the Enumtype called
							<code>ContractType</code></li>
						<li>You want to be able to let the user select the appropriate type of contract</li>
						<li>In your controller (e.g. SimpleFormController), you have implemented the
						<code>referenceData()</code> method that returns a List of the available contract types
						under the key <code>contractTypes</code></li>
					</ul>
					To display the select widget form which the user can select a contract type:

<pre>
&lt;form method="post"&gt;
    ## bind on the contractType property
    &lt;spring:bind path="Contract.contractType"&gt;
        ## render the select box
        &lt;select name="&lt;c:out value="${status.expression}"/&gt;"&gt;
            ## iterate over all the contracttypes available
            &lt;c:forEach items="${contractTypes}" var="type"&gt;
                ## transform the contract type using the property editor 
                ## used to create the BindStatus object
                &lt;spring:transform value="${type}" var="typeString"/&gt;
                &lt;option 
                    ## output the value (databinding will be able to use this!)
                    value="&lt;c:out value="${typeString}"/&gt;
                    ## see if it is selected
                    &lt;c:if test="${status.value == typeString}"/&gt; selected&lt;/c:if&gt;&gt;
                    ## you could also use the itemString var for i18n (spring:message)
                    &lt;c:out value="${itemString}"/&gt;
                &lt;/option&gt;
            &lt;/c:forEach&gt;
        &lt;/select&gt;
    &lt;/spring:bind&gt;
&lt;/form&gt;	
</pre>
				<td>
			</tr>
		</table>
	</body>
</html>